﻿Imports extremo

Public Class ProveedoresEditar
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then

            Dim id = Request.Params.Get("id")

            Dim negocio = New ProveedorNegocio
            Dim modelo = negocio.obtener(id)

            Me.txtidproveedor.Value = modelo.idproveedor
            Me.txtNombre.Text = modelo.nombre
            Me.txtruc.Text = modelo.ruc
            Me.txtdireccion.Text = modelo.direccion
            Me.txttelefono.Text = modelo.telefono

        End If

    End Sub

    Protected Sub btnRegresar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnRegresar.Click
        Response.Redirect("Proveedores.aspx", True)
    End Sub

    Protected Sub btnGuardar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGuardar.Click
        Try
            Dim negocio = New ProveedorNegocio
            negocio.actualizar(Me.txtIdproveedor.Value, Me.txtNombre.Text, Me.txtruc.Text, Me.txtdireccion.Text, Me.txttelefono.Text)

            Response.Redirect("Proveedores.aspx", True)
        Catch ex As Exception
            Response.Write("No se pudo actualizar")
        End Try
    End Sub
End Class